/**
 * <p>Title: CNPEC 组合url参数 </p>
 * <p>Description: IMS</p>
 * <p>Copyright: Copyright (c) 2009</p>
 * <p>Company: CNPEC</p>
 */
package com.mes.cloud.domain.helpers;

import com.sun.jndi.toolkit.url.Uri;

/**
 * 组合参数
 * 
 * @author yang yi
 * @version 1.0 $Id: UrlHelper.java,v 1.0 2009/07/20$
 */
public class UrlHelper {

    /**
     * 组合url
     * @param url 需要组合的url
     * @param paramName 参数名
     * @param value 参数值
     */
    public static void addParam(StringBuffer url, String paramName, String value) {
	Uri uri;
	try {
	    uri = new Uri(url.toString());

	    if (uri.getQuery() == null || "".equals(uri.getQuery())) {
		String eval = java.net.URLEncoder.encode(value, "UTF-8");
		url.append("?" + paramName + "=" + eval);
	    } else {
		String eval = java.net.URLEncoder.encode(value, "UTF-8");
		url.append("&" + paramName + "=" + eval);
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}
